package com.example.springbootelasticsearch;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Document(indexName = "products") // 指定索引名称
@Data
public class Product {

    @Id // 标记主键字段
    private String id;

    @Field(type = FieldType.Text) // 定义字段类型为 Text，支持全文搜索
    private String name;

    @Field(type = FieldType.Keyword) // 定义字段类型为 Keyword，用于精确匹配
    private String category;

    @Field(type = FieldType.Double) // 定义字段类型为 Double
    private double price;
}
